package com.kuang.mapper;

import com.kuang.pojo.User;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

/**
 * @program: spring-study
 * @description:
 * @author: 陈恩涛
 * @create: 2020-07-18 21:06
 **/
public class UserMapperImpl extends SqlSessionDaoSupport implements UserMapper {

    //我们的所有操作，在原来都是用sqlSession来执行，现在都是用sqlSessionTemplate

    @Override
    public List<User> getUsers() {

        UserMapper mapper = getSqlSession().getMapper(UserMapper.class);
        User user = new User(5, "飞机", "feji");

        mapper.addUser(user);
        mapper.deleteUser(1);

        return mapper.getUsers();
    }

    @Override
    public int addUser(User user) {
        return getSqlSession().getMapper(UserMapper.class).addUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return getSqlSession().getMapper(UserMapper.class).deleteUser(id);
    }
}
